<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // es5 原生继承
    // 构造函数 + 原型对象 

    function Animal(name){
      this.name = name
    }

    Animal.prototype.bark = function(){
      console.log("名字是"+this.name);
    }


    function Dog(name,color){
      // 构造函数中借用父类的构造函数
      Animal.call(this,name)
      this.color = color
    }
    // 把被继承对象是的实例对象赋值给继承对象的原型对象
    Dog.prototype = new Animal()
    var wc = new Dog('旺财','yellow')
    wc.bark()
    console.log("wc.name==>",wc.name);
    console.log("wc.name==>",wc.color);



  </script>
</body>
</html>